﻿using Tisbi.LawFirm.BL.Services;
using Tisbi.LawFirm.DAL.Models;
using Tisbi.LawFirm.UI.Views.Controls.Forms;

namespace Tisbi.LawFirm.UI.ViewModel
{
    public class StatementOfClaimTypesViewModel : BaseViewModel<StatementOfClaimType, IServiceAgentBase<StatementOfClaimType>>
    {
        protected override void LoadModelBySearch()
        {
            IsBusy = true;

            ModelServiceAgent.GetItem
                (
                    (list, exception) =>
                        ModelLoadedByWhere(list, exception, item => item.StatementOfClaimTypeTitle.Contains(SearchCriteria))
                );
        }

        protected override void ShowEditDialog()
        {
            if (SelectedModelItem == null)
            {
                return;
            }

            var model = new StatementOfClaimTypesCRUDViewModel(SelectedModelItem);
            ShowEditDialog<StatementOfClaimCRUDForm>(model, "Карточка изменения типа иска");
        }

        protected override void ShowCreatedDialog()
        {
            var newItem = new StatementOfClaimType();
            var detailModel = new StatementOfClaimTypesCRUDViewModel(newItem);

            ShowCreatedDialog<StatementOfClaimCRUDForm>(detailModel, "Карточка создания нового федерального округа");
        }
    }
}
